package com.ruoyi.web.controller.rjgc;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.littleRedBook.domain.pojo.Order;
import com.ruoyi.littleRedBook.service.AdminOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/admin/order")
@Api(tags = "管理端-订单管理")
public class AdminOrderController {

    @Autowired
    private AdminOrderService adminOrderService;

    @GetMapping("/list")
    @ApiOperation("获取所有订单列表（分页）")
    public AjaxResult getAllOrders(
            @ApiParam("订单号搜索") @RequestParam(required = false) String orderNo,
            @ApiParam("买家ID搜索") @RequestParam(required = false) Long buyerId,
            @ApiParam("订单状态：0-待付款 1-待发货 2-待收货 3-已完成 4-已取消") @RequestParam(required = false) Integer status,
            @ApiParam("页码，默认1") @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam("每页条数，默认10") @RequestParam(defaultValue = "10") Integer pageSize) {
        return adminOrderService.getAllOrders(orderNo, buyerId, status, pageNum, pageSize);
    }

    @GetMapping("/{id}")
    @ApiOperation("获取订单详情")
    public AjaxResult getOrderDetail(@ApiParam("订单ID") @PathVariable Long id) {
        return adminOrderService.getOrderDetail(id);
    }

    @GetMapping("/statistics")
    @ApiOperation("订单统计（今日/本月/总订单数、金额）")
    public AjaxResult getOrderStatistics() {
        return adminOrderService.getOrderStatistics();
    }
}
